package com.learn.juc;

import java.util.concurrent.*;

/**
 * ClassName:MyThreadPool
 * Package:com.learn.juc
 * Description:
 *
 * @Author:@郭先森
 * @Create:2025/7/28 - 20:45
 * @Version:v1.0
 */

//自定义线程池
public class MyThreadPool {
    public static void main(String[] args) {
        ExecutorService executorService = new ThreadPoolExecutor(2,5,
                              2L, TimeUnit.SECONDS,
                                           new ArrayBlockingQueue<>(3),
                                           Executors.defaultThreadFactory(),
                                           new ThreadPoolExecutor.AbortPolicy());


        //处理10个请求
        for (int i = 0; i < 10; i++) {
            //执行
            executorService.execute(()->{
                System.out.println(Thread.currentThread().getName()+"正在办理业务");
            });
        }
        executorService.shutdown();
    }
}
